<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
      <#include "/common/elibs.html">
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
  </head>
  <script>var index;
  </script><body>
    <div class="x-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <input type="hidden" id="userBaseInfoId" name="userBaseInfoId" lay-verify="required" value="${id}" >
              <label for="oldUserPassword" class="layui-form-label">
                  <span class="x-red">*</span>原始密码
              </label>
              <div class="layui-input-inline">
                  <input type="password" id="oldUserPassword" name="oldUserPassword" lay-verify="required" placeholder="请输入"
                  autocomplete="off" class="layui-input" >
              </div>
              <div class="layui-form-mid layui-word-aux">
                  <span class="x-red">*</span>
              </div>
          </div>
            <div class="layui-form-item">
                <label for="newPwd" class="layui-form-label">
                    <span class="x-red">*</span>新密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="userPassword" name="userPassword" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="newPwd" class="layui-form-label">
                    <span class="x-red">*</span>确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="newPwd" name="newPwd" lay-verify="required" placeholder="请输入"
                           autocomplete="off" class="layui-input" >
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

          <div class="layui-form-item">
              <label for="newPwd" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  提交
              </button>
          </div>
      </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
            var form = layui.form
                ,layer = layui.layer, layedit = layui.layedit;
            //自定义验证规则
            /*form.verify({
                newPwd: [/(.+){6,12}$/, '密码必须6到12位'],
                repass: function(value){
                    if($('#userPassword').val() != $('#newPwd1').val()){
                        return '两次密码不一致';
                    }
                }
            });*/

            //监听提交
            form.on('submit(add)', function(t){
                var isOver = true;
                if($("#userPassword").val() != $("#newPwd").val()){
                    layer.open({
                        title: '提示信息'
                        ,content: "两次密码不一致"
                    });
                    isOver = false;
                    return false;
                }
                if(isOver){
                    var params = {
                        // tcaDescribe : layui.layedit.getContent(index),
                        userPassword : $("#userPassword").val(),
                        oldUserPassword : $("#oldUserPassword").val(),
                        userBaseInfoId : $("#userBaseInfoId").val(),
                    }
                    if(true){
                        ajaxFun('post','/pc/user/updateUserPassword',params,function(data){
                            if(data.code != 0){
                                alertFun(data);
                            }else{
                                window.location.href= path + "/modules/users/list.html";
                                console.log("success !");
                            }
                        })
                    }
                }

                //发异步，把数据提交给php
                /*layer.alert("增加成功", {icon: 6},function () {
                    // 获得frame索引
                    var index = parent.layer.getFrameIndex(window.name);
                    //关闭当前frame
                    parent.layer.close(index);
                });*/
                return false;
            });


        });
    </script></body></html>